package com.chen.demo.javase.annotaion.spi;

import java.util.Iterator;
import java.util.ServiceLoader;

/**
 * @author chenhongwei
 * @date 2019/10/7 22:56
 **/
public class SPITest {
    public static void main(String[] args) {
        ServiceLoader<SPIDemoService> services = ServiceLoader.load(SPIDemoService.class);
        Iterator<SPIDemoService> iterator = services.iterator();
        while (iterator.hasNext()) {
            SPIDemoService serviceImpl = iterator.next();
            System.out.println(serviceImpl.sayHi(""));
        }
        System.out.println("end");
    }
}
